﻿using UnityEngine;
using System.Collections;

public class PlayerAttackController : MonoBehaviour {

	public GameObject playerObject = null;
	public Transform SpawnPoint = null;
	private float selfDestructTime = 0.0f;

	public void LaunchAttack()
	{
		float mainXScale = playerObject.transform.localScale.x;	
		Vector3 AttackSide = transform.localScale;
		if (mainXScale < 0.0f) 
		{
			//invertendo lado do attack
			AttackSide.x *= -1;
			transform.localScale = AttackSide;
		}
		selfDestructTime = Time.time + 0.5f;	
	}
	
	void Update () {
		if (selfDestructTime > 0.0f) 
		{
			if (selfDestructTime < Time.time) 
			{
				Destroy(gameObject);
			}
			else
			{
				this.transform.position = SpawnPoint.position;
			}
		}
	}
}
